<?php

use think\facade\Route;

$version = request()->header('version') ?? 'v1';

Route::group('user', function() use ($version) {

    /**
     * 不需验证
     */
    Route::group('', function () use ($version) {
    });

    /**
     * 需验证
     */
    Route::group('', function () use ($version) {
        /*
         * 首页
         */
        Route::rule('home/:action', 'api.' . $version . '.user.home.HomeController/:action');
        // 公告
        Route::rule('placard/:action', 'api.' . $version . '.user.home.PlacardController/:action');

        /*
         * 心理测试
         */
        // 分类
        Route::rule('sc/:action', 'api.' . $version . '.user.scale.CategoryController/:action');
        // 多元智能题型
        Route::rule('multi/:action', 'api.' . $version . '.user.scale.MultiController/:action');
        // 我的测试订单
        Route::rule('om/:action', 'api.' . $version . '.user.order.MultiController/:action');

        /*
         * 心理咨询
         */
        // 专家相关
        Route::rule('expert/:action', 'api.' . $version . '.user.expert.ExpertController/:action');
        // 专家关注
        Route::rule('follow/:action', 'api.' . $version . '.user.expert.FollowController/:action');
        // 专家评价
        Route::rule('eval/:action', 'api.' . $version . '.user.expert.EvaluateController/:action');

        /*
         * 心理课程
         */
        Route::rule('cc/:action', 'api.' . $version . '.user.course.CategoryController/:action');
        Route::rule('course/:action', 'api.' . $version . '.user.course.CourseController/:action');
        Route::rule('collect/:action', 'api.' . $version . '.user.course.CollectController/:action');
        // 我的课程订单
        Route::rule('oc/:action', 'api.' . $version . '.user.order.CourseController/:action');

        /*
         * 我的
         */
        Route::rule('mine/:action', 'api.' . $version . '.user.mine.MineController/:action');
        // 元心币
        Route::rule('coin/:action', 'api.' . $version . '.user.mine.CoinController/:action');
        // 心理咨询订单
        Route::rule('consult/:action', 'api.' . $version . '.user.order.ConsultController/:action');
        // 心理咨询订单退款
        Route::rule('cr/:action', 'api.' . $version . '.user.order.ConsultRefundController/:action');
        // 心理咨询订单退款日志
        Route::rule('crl/:action', 'api.' . $version . '.user.order.ConsultRefundLogController/:action');
        // 邀请
        Route::rule('invite/:action', 'api.' . $version . '.user.mine.InviteController/:action');

        /*
         * 中国地区
         */
        Route::rule('region/:action', 'api.' . $version . '.user.region.RegionController/:action');

        /*
         * 系统相关
         */
        Route::rule('site/upload', 'api.' . $version . '.user.site.SiteController/upload');
        Route::rule('site/logout', 'api.' . $version . '.user.site.SiteController/logout');

        /*
         * trtc
         */
        Route::rule('trtc/:action', 'api.' . $version . '.user.trtc.TrtcController/:action');

        /*
         * 消息
         */
        // 用户聊天
        Route::rule('chat/:action', 'api.' . $version . '.user.mine.ChatController/:action');
    })->middleware([
        "app\middleware\user\\$version\AuthMiddleware"
    ]);
})->middleware([
    'cors'
]);
